<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改发芽率')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-ncSeedRate-edit" th:object="${ncSeedRate}">
        <input id="seedRateId" name="seedRateId" th:field="*{seedRateId}" type="hidden">
        <!--作物品种ID-->
        <input id="treeId" name="cropVarieties" type="hidden" th:value="*{cropVarieties}"/>

        <div class="form-group">
            <label class="col-sm-3 control-label">蔬菜批次：</label>
            <div class="col-sm-8">
                <input id="caiCode" name="caiCode" required th:field="*{caiCode}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">作物品种：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input class="form-control" name="cropVarietiesCn" required th:field="*{cropVarietiesCn}"  type="text"  onclick="selectCaiTree()" id="treeName" readonly="true">
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">育苗盘编号：</label>
            <div class="col-sm-8">
                <input id="seedCode" name="seedCode" required th:field="*{seedCode}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">育苗盘规格：</label>
            <div class="col-sm-8">
                <input id="seedUnit" name="seedUnit" required th:field="*{seedUnit}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">育苗数量(株)：</label>
            <div class="col-sm-8">
                <input id="amount" name="amount" required th:field="*{amount}" class="form-control" type="number" min="1" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">播种种子数：</label>
            <div class="col-sm-8">
                <input id="seedCount" name="seedCount" th:field="*{seedCount}" class="form-control" type="number" min="1" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">发芽/出苗数：</label>
            <div class="col-sm-8">
                <input id="seedOut" name="seedOut" required th:field="*{seedOut}" class="form-control" type="number" min="1" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">发芽率/出苗数：</label>
            <div class="col-sm-8">
                <input id="seedRate" name="seedRate" required th:field="*{seedRate}" class="form-control" type="number" min="1"
                       step="0.01">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">日期：</label>
            <div class="col-sm-8">
                <input id="createTime" data-format="yyyy-MM-dd" name="createTime" required
                       th:value="*{#dates.format(createTime, 'yyyy-MM-dd')}" class="form-control"
                       type="text" th:class="time-input">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea rows="3" id="remark" name="remark" th:field="*{remark}" class="form-control"
                          type="text"></textarea>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "system/ncSeedRate";
    var cai_prefix = ctx + "system/cai";
    $("#form-ncSeedRate-edit").validate({
        rules: {
            xxxx: {
                required: true,
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-ncSeedRate-edit').serialize());
        }
    }

    /*蔬菜管理-新增-选择父蔬菜树*/
    function selectCaiTree() {
        var options = {
            title: '蔬菜选择',
            width: "380",
            url: cai_prefix + "/selectCaiTree/" + $("#treeId").val()+'?parentIds=210,',
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        if ($.tree.notAllowParents(tree)) {
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    }
</script>
</body>
</html>
